﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NavLine.Aircraft
{
	public partial class AC
	{
		public AC_Config config;

		public V3G position;

		public double speed;
		public double acc;

		public AC(AC_Config iconfig, V3G ipos, double ispeed, double ihead)
		{
			config = iconfig;

			position = ipos;
			heading = ihead;
			speed = ispeed;

			Ctrl = new AC_Controller(this);
		}

		void UpdatePosition(double dt)
		{
			speed += acc * dt;
			UpdateHeading(dt);
			position.Move(heading, speed * dt, out heading);
		}

		public double Elevation;
		public double Climb;
		public double ROC;

		void UpdateElevation(double dt)
		{
			Climb += ROC * dt;
			Elevation += Climb * dt;
		}

		//AC_Navigator N;
		AC_Controller Ctrl;
		public void Process(double dt)
		{
			//N.process(dt);
			Ctrl.Process(dt);

			UpdatePosition(dt);
			UpdateElevation(dt);
		}

		public void HeadTo(double hdg)
		{
			Ctrl.MaintainHeading(hdg);
		}
		public void GoTo(V3G pt)
		{
			Ctrl.NavigateToPoint(pt);
		}
		public void GoLine(Line3G L, double enddist)
		{
			Ctrl.NavigateLine(L, enddist);
		}
		public void GoLineSegment(double segmentdist, double finaldist, params V3G[] iline)
		{
			Ctrl.NavigateSegment(segmentdist, finaldist, iline);
		}
	}
}